//Copyright (C) 2009 Ron Coleman. Contact: ronncoleman@gmail.com
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 3 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this library; if not, write to the Free Software
//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

package org.workplicity.marist.grounds.util;

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import org.workplicity.util.WorkDate;

/**
 * Grounds data formatter.
 * TODO: Use DateFormatter in the utils project.
 * @author Ron Coleman
 */
public class GroundsDate extends Date {
    private Calendar calendar = Calendar.getInstance(Locale.getDefault());

    public GroundsDate(long time) {
        super(time);
    }

    public GroundsDate(WorkDate date) {
        super(date.getTime());
    }

    @Override
    public String toString() {
        calendar.setTime(this);
        
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        int mon = calendar.get(Calendar.MONTH) + 1;
        int yyyy = calendar.get(Calendar.YEAR);

        String days = day < 10 ? "0"+day : day+"";
        String mons = mon < 10 ? "0"+mon : mon+"";

        return mons + " / " + days + " / " + yyyy;
    }
}
